package com.itheima.controller.backend.controller;

import com.itheima.common.entity.Result;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ReportService reportService;

    @GetMapping("/getMemberReport")
    public Result getMemberReport() {
        return new Result(true, "获取会员统计数据成功",reportService.getMemberReport());
    }

    @GetMapping("/getSetmealReport")
    public Result getSetmealReport() {
        return new Result(true, "获取套餐统计数据成功",reportService.getSetmealReport());
    }

    /**
     * 获取运营统计数据
     */
    @GetMapping("/getBusinessReportData")
    public Result getBusinessReportData() {
        return new Result(true, "获取运营统计数据成功",reportService.getBusinessReportData());
    }

    /**
     * 导出运营数据报表
     */
    @GetMapping("/exportBusinessReport")
    public String exportBusinessReport(HttpServletResponse response) {
        reportService.exportBusinessReport(response);
        return "下载文件";
    }

}
